import $router from '@/router';

export default {
	goHome: function(){
		//if($router.path!='/home'){
			this.goRouter('desktop');
			//$router.push( '/home' );
		//}
	},
	goLogin: function() {
		if($router.path!='/login'){
			$router.push( '/login' );
		}
	},
	quit:function() {//退出使用页面刷新方式，目的是清除 vue 页面缓存
		//window.location.reload();
		//window.location.replace("./#/login");
		if($router.path!='/login'){
			$router.push( '/login' );
		}
	},
	
	/******************************************************************************/
	goRouter(name) {
		let list = $router.getRoutes();
		let r = list.filter(item => {
			if(item.name == name && $router.path != item.path){
				return item;
			}
		})[0];
		if(r){
			//console.log("goHome===>" +JSON.stringify(r));
			$router.push(r.path);
		}
	}
}